/**
 * Ingenius-Group S.A.S
 * Project: SAU
 * File: Person.java
 * Date: 17/11/2010
 */

package com.ingenius.sau.shared.model.users;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NullValue;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.ingenius.sau.shared.model.core.BaseBean;

/**
 * Class <strong>Person</strong>
 * 
 * @author Jesus David
 * @version 0.1
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Person implements BaseBean {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id;

	@Persistent(nullValue = NullValue.NONE)
	private String firstname;

	@Persistent(nullValue = NullValue.NONE)
	private String lastname;

	@Persistent
	private String email;

	@Persistent
	private String phone;

	@Persistent
	private String photo;

	// CONSTRUCTORS

	public Person() {
	}

	public Person(String id) {
		this.id = id;
	}

	// METHODS

	public String getId() {
		return id;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Person) {
			return ((Person) obj).getId().equals(id);
		}
		return false;
	}

	public Person toDTO() {
		return this;
	}
}
